<%@ page import="com.uca.sisbec.commons.SisbecAction" %>
<%@ page import="java.io.PrintWriter" %>

<html>
    <head>
        <title>Pagina de Errores</title>
        <script>
            function ShowStackTrace() {
                var control = document.getElementById("stackLayer");
                if (control.style.visibility == "hidden") {
                    control.style.visibility = "visible";
                }
                else {
                    control.style.visibility = "hidden";
                }
            }
        </script>
    </head>
<%

Throwable e;
Object temp = request.getAttribute(SisbecAction.EXCEPTION);
String toStr = "";
String className="";
if ( temp!= null && temp instanceof Throwable){  
  e = (Throwable)request.getAttribute(SisbecAction.EXCEPTION);
}
else{
	toStr = temp.toString();
	className = temp.getClass().getName();
  e = new Throwable("Error Desconocido");
}  
%>
    <body>
        <h3>Se ha detectado una operacion no valida en el sistema</h3>
        <table>
            <tr>
                <td><font><li>to String: <code><%=toStr%></code></li></font></td>
            </tr>
            <tr>
                <td><font><li>Clase: <%=className%></li></font></td>
            </tr>
            <tr>
                <td><font><li>Mensaje</li></font></td>
            </tr>
            <tr>
                <td><b><font color="aa0000"><%=e.getMessage()%></font></b></td>
            </tr>
        </table>
        <table>
            <tr>
                <td><a href="#" onClick="ShowStackTrace();"><li>StackTrace</li></a></td>
            </tr>
            <tr>
                <td>
                    <div style="visibility: hidden" id="stackLayer">
                        <table>
                            <tr>
                                <td><font><li>Tipo de excepcion</li></font></td>
                            </tr>
                            <tr>
                                <td><b><%=e.getClass().getName()%></b></td>
                            </tr>
                            <tr>
                                <td>
                                    <div>
                                        <%
                                            PrintWriter pw = new PrintWriter(out);
                                            e.printStackTrace(pw);
                                        %>
                                    </div>
                                </td>
                            </tr>
                        </table>
                    </div>
                </td>
            </tr>
        </table>
    </body>
</html>